{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import yfinance as yf\n",
    "import talib \n",
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                  Open        High         Low       Close    Volume  \\\n",
      "Date                                                                   \n",
      "2020-01-13  194.750000  197.750000  191.399994  196.250000  40535961   \n",
      "2020-01-14  195.699997  198.250000  193.600006  195.850006  29867542   \n",
      "2020-01-15  195.000000  201.699997  194.000000  200.350006  38485962   \n",
      "2020-01-16  199.500000  200.600006  196.899994  197.550003  28118140   \n",
      "2020-01-17  197.250000  199.449997  195.699997  197.300003  18204088   \n",
      "...                ...         ...         ...         ...       ...   \n",
      "2022-01-05  486.950012  492.750000  483.549988  489.750000  15420105   \n",
      "2022-01-06  481.500000  492.950012  477.100006  488.850006  16563230   \n",
      "2022-01-07  490.049988  495.500000  483.750000  490.600006  15532165   \n",
      "2022-01-10  493.100006  504.899994  491.299988  503.700012  25193771   \n",
      "2022-01-11  503.000000  507.899994  498.149994  501.299988  16259406   \n",
      "\n",
      "            Dividends  Stock Splits       MA_10      RSI_14     ATR_14  \\\n",
      "Date                                                                     \n",
      "2020-01-13          0             0         NaN         NaN        NaN   \n",
      "2020-01-14          0             0         NaN         NaN        NaN   \n",
      "2020-01-15          0             0         NaN         NaN        NaN   \n",
      "2020-01-16          0             0         NaN         NaN        NaN   \n",
      "2020-01-17          0             0         NaN         NaN        NaN   \n",
      "...               ...           ...         ...         ...        ...   \n",
      "2022-01-05          0             0  479.705002  474.171430  14.458624   \n",
      "2022-01-06          0             0  481.355002  475.503573  14.558008   \n",
      "2022-01-07          0             0  483.655002  478.614288  14.357436   \n",
      "2022-01-10          0             0  486.910004  482.192860  14.353333   \n",
      "2022-01-11          0             0  489.020001  484.392859  14.024523   \n",
      "\n",
      "            Upper_Band  Middle_Band  Loewer_Band  \n",
      "Date                                              \n",
      "2020-01-13         NaN          NaN          NaN  \n",
      "2020-01-14         NaN          NaN          NaN  \n",
      "2020-01-15         NaN          NaN          NaN  \n",
      "2020-01-16         NaN          NaN          NaN  \n",
      "2020-01-17         NaN          NaN          NaN  \n",
      "...                ...          ...          ...  \n",
      "2022-01-05  507.597179   479.757503   451.917827  \n",
      "2022-01-06  506.907552   479.502502   452.097453  \n",
      "2022-01-07  506.343940   479.310002   452.276064  \n",
      "2022-01-10  507.970285   479.727502   451.484720  \n",
      "2022-01-11  509.828462   480.322502   450.816542  \n",
      "\n",
      "[498 rows x 13 columns]\n"
     ]
    }
   ],
   "source": [
    "# pd.set_option(\"display.max_rows\",None)\n",
    "# pd.set_option(\"display.max_columns\",None)\n",
    "# pd.set_option(\"display.width\",None)\n",
    "\n",
    "symbol = \"TATAMOTORS.NS\"\n",
    "df = yf.Ticker(symbol).history(period='2y',interval='1d')\n",
    "df[\"MA_10\"] = talib.MA(df['Close'], timeperiod  =10)\n",
    "df[\"RSI_14\"] = talib.MA(df['Close'], timeperiod  =14)\n",
    "df[\"ATR_14\"] = talib.ATR(df['High'],df['Low'],df['Close'], timeperiod=14 )\n",
    "df[\"Upper_Band\"],df[\"Middle_Band\"],df[\"Loewer_Band\"] = talib.BBANDS(df[\"Close\"],timeperiod  =20,nbdevup = 2, nbdevdn =2)\n",
    "\n",
    "\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
